package org.dslmagic.data;

import org.dslmagic.dsl.Dsl;

public abstract class Transformer {
	public static final Transformer TO_OBJ;
	public static final Transformer TO_BOOL;
	public static final Transformer TO_STR;
	public static final Transformer TO_INT;
	public static final Transformer TO_GROUP;
	public static final Transformer TO_DSL;

	static {
		TO_OBJ = new Transformer() {
			@Override
			public Object transform(Object target) {
				return target;
			}
		};
		TO_BOOL = new Transformer() {
			@Override
			public Object transform(Object target) {
				return Boolean.TRUE.equals(target);
			}
		};
		TO_STR = new Transformer() {
			@Override
			public Object transform(Object target) {
				return String.valueOf(target);
			}
		};
		TO_INT = new Transformer() {
			@Override
			public Object transform(Object target) {
				return Integer.valueOf(String.valueOf(target));
			}
		};
		TO_GROUP = new Transformer() {
			@Override
			public Object transform(Object target) {
				return Group.from(target);
			}
		};
		TO_DSL = new Transformer() {
			@Override
			public Object transform(Object target) {
				return (Dsl) target;
			}
		};
	}

	public abstract Object transform(Object target);

}
